package me.pearjelly.pmc;

import me.pearjelly.pmc.index.Worker;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class IndexApp {

	private static ApplicationContext context;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		init();
		
		start(args.length>0 && "init".equals(args[0]));

	}

	private static void init(){
		context = new ClassPathXmlApplicationContext("spring-*.xml");
	}
	
	private static void start(boolean init){
		Worker worker = null;
		if(init){
			worker = (Worker)context.getBean("initWorker");
		}else{
			worker = (Worker)context.getBean("worker");
		}
		worker.run();
	}
}
